#ifndef _GA
#define _GA

#include <vector>
#include <time.h>
#include <cv.h>
#include <highgui.h>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/discrete_distribution.hpp>
#include <boost/random/uniform_int_distribution.hpp>
#include "complexity.h"

using namespace std;
using namespace cv;

class GA {
    vector<Mat> population;
    vector<Mat> prevPopulation;
    vector<double> comp;
    int charSize;
    boost::random::mt19937 gen;
public:
    GA(int, int); // constructor
    bool compare(Mat, Mat); // compare two matrices for ordering

    void randomInit(); // randomly initialize population

    unsigned int getPopulationSize() { return population.size(); }

    void crossOver(int, int); // crossover two members
    void mutate(int); // mutate member

    Mat getMember(int i) { return population.at(i); }

    void updateComplexities(); // update all complexities of population
    void sortComplexities(); // sort current population by complexity

    void advance(); // copy current population to previousp population
    void evolve(); // do one evolution step

    void printComplexities(); // print complexities, for debugging purposes

    void display(int); // display certain member of population

};

#endif
